<?php

function getItemsByCategory($method_name, $args, $app_data){
	$orgid=$args[0];
	$catid=$args[1];
	
	$catresult=mysql_query("Select objid from products	 where catid=".$catid." and orgid=".$orgid);

	$catarray=array();
	
	while($objrow = mysql_fetch_array($catresult)){
		$objid=$objrow[0];
		
		$result=mysql_query("Select distinct item_unique_key from items_attributes where objid=".$objid." and orgid=".$orgid);
		$num=mysql_numrows($result);
		$keysarray=array();
		
		$i=0;
		while ($i < $num) {
		
			$keysarray[]=mysql_result($result,$i,"item_unique_key");
			$i++;
		}
		
		$resultarray=array();
		foreach($keysarray as $itemkey){
			$query="SELECT a.attribute_name, i.item_value, i.item_unique_key".
						   " FROM items_attributes AS i".
						   " INNER JOIN product_attributes AS p ON p.prod_attr_id = i.prod_attr_id".
						   " INNER JOIN attributes AS a ON a.id = p.attr_id".
						   " WHERE i.orgid=".$orgid." and i.objid=".$objid." and i.item_unique_key='".$itemkey."'".
						   " ORDER BY i.item_unique_key";
		
			$result=mysql_query($query);
			$num=mysql_numrows($result);
			$itemarray=array();
			while($row = mysql_fetch_array($result))
			{
				$itemarray[$row[0]]=$row[1];
			}
		
			$resultarray[]=$itemarray;
		
		}
		
		$catarray[]=$resultarray;
	}


	return $catarray;

}

function calculateTotal($method_name, $args, $app_data){
	
	echo "Test";
}

function verifyCreditCard($method_name, $args, $app_data){
	echo "Test";
}

function calculateTax($method_name, $args, $app_data){
	echo "Test";
}


function calculateDiscount($method_name, $args, $app_data){
	echo "Test";
}

function calculateShippingCharge($method_name, $args, $app_data){
	echo "Test";
}

function confirmOrder($method_name, $args, $app_data){
	echo "Test";
}

function billToCreditCard($method_name, $args, $app_data){
	echo "Test";
}

function convertCurrency($method_name, $args, $app_data){
	echo "Test";
}

function availCoupon($method_name, $args, $app_data){
	echo "Test";
}

function calculateGiftCharges($method_name, $args, $app_data){
	echo "Test";
}

function suggestProducts($method_name, $args, $app_data){
	echo "Test";
}

function captcha($method_name, $args, $app_data){
	echo "Test";
}

function validateCaptcha($method_name, $args, $app_data){
	echo "Test";
}


function promitionalOffers($method_name, $args, $app_data){
	echo "Test";
}

function makePayment($method_name, $args, $app_data){
	echo "Test";
}

function confirmOrderViaEmail($method_name, $args, $app_data){
	echo "Test";
}


function sendInvoiceViaEmail($method_name, $args, $app_data){
	echo "Test";
}
